/*
 *    This file is part of CeluMap.
 *
 *    CeluMap is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU Lesser General Public License as published by
 *    the Free Software Foundation; either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    CeluMap is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *    Copyright 2006, 2007, 2008 Gonzalo Merayo
 *    gonzalo (at) celumap.com.ar
 *    www.celumap.com.ar
 *
 */

package service;

import file.HomeGetter;
import map.file.CombinationMap;


public class ServicesMap extends CombinationMap implements Runnable{
	
	Thread t = null;
	public ServicesMap(String spec){
		if(spec!=null){
			load(spec);
			startThread();
		}
	}
	
	private void startThread() {
		t = new Thread(this);
		t.start();
	}

	private void load(String spec) {
		appendMap(new Service(HomeGetter.getInstance(), "r.map", 60, "Restorantes"));
		appendMap(new Service(HomeGetter.getInstance(), "f.map", 60, "Farmacias"));
		appendMap(new Service(HomeGetter.getInstance(), "e.map", 60, "Est Servicio"));
	}

	private void refresh(){
		for(int i=0; i<cuadrantes.length;i++)
			if (cuadrantes[i] instanceof GisService) {
				GisService service = (GisService) cuadrantes[i];
				service.refresh();
			}
	}

	public void run() {
		refresh();
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
